#ifndef CPP_MOTIONEVENT_H
#define CPP_MOTIONEVENT_H

#include <sys/time.h>

//@brief 触摸事件
//@author cvte
class MotionEvent {
   public:
    const static int UP = 0;
    const static int DOWN = 1;
    const static int MOVE = 2;
    const static int MOVEIN = 3;
    const static int MOVEOUT = 4;

    MotionEvent() : mAction(UP), mX(0), mY(0) {
        gettimeofday(&mTimeval, nullptr);
    };
    MotionEvent(int action, int x, int y) : mAction(action), mX(x), mY(y) {
        gettimeofday(&mTimeval, nullptr);
    };
    ~MotionEvent(){};

    void init(int action, int x, int y) {
        mAction = action;
        mX = x;
        mY = y;
    }

    void setAction(int action) {
        mAction = action;
    }

    int getAction() {
        return mAction;
    }

    void setX(int x) {
        mX = x;
    }

    int getX() {
        return mX;
    }

    void setY(int y) {
        mY = y;
    }

    int getY() {
        return mY;
    }

    struct timeval getTime() {
        return mTimeval;
    }

   private:
    int mAction = UP;
    int mX = 0;
    int mY = 0;
    struct timeval mTimeval;
};

#endif /* CPP_MOTIONEVENT_H */